package com.chixing.controller;

import com.chixing.service.MyorderTravelerService;
import com.chixing.util.ServerResponse;
import com.sun.deploy.net.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

@RestController
@ResponseBody
public class MyorderTravelerController {

    @Autowired
    private MyorderTravelerService myorderTravelerService;

    @RequestMapping(value = "saveMyorderTraveler/{myOrderId}",method = RequestMethod.POST)
    public @ResponseBody void saveMyorderTraveler(@PathVariable("myOrderId")Integer myOrderId,@RequestBody Map map){


        System.out.println("+++++++++++++++++++++++++++++++++++++++");

        Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();

        //新建一个Map
        HashMap<String, String> ObjectHashMap = new HashMap<>();
        int length = map.size();
        System.out.println("length:" + length);
        for (int i = 0; i < length ; i++){
            while (iterator.hasNext()){
                Map.Entry<String, String> next = iterator.next();
                String key = next.getKey();
                String value = next.getValue();
                myorderTravelerService.saveMyorderTraveler(myOrderId,key,value);
            }
        }

        System.out.println("---------------------------------------");
    }
}
